﻿<%@ Page Language="C#" MasterPageFile="~/View/Shared/EHSubmit.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" Title="EHSubmit作业管理系统-登录" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<style type="text/css">
    .allow-float{clear:none !important;}
    .stop-float{clear:both !important;}
    .float-left{float:left;}
</style>
<title>登录</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">

<script language="javascript" type="text/javascript">
    Ext.onReady(function() {
    
    Ext.QuickTips.init();
    
    Ext.form.Field.prototype.msgTarget = 'qtip';
    

    EHSubmit.loginForm = new Ext.FormPanel({
        name: 'loginForm',
        id: 'loginForm', 
        autoTabs: true,
        deferredRender: false,
        border: false,
        items:[
            {
                html:"<img src='images/login_head.jpg'/>",
                xtype:'box'
            },
            {
                xtype: 'tabpanel',
                border:false,
                activeTab: 0,
                defaults:{autoHeight:true, bodyStyle:'padding:30px',border:false},
                items:[{ //tab1--
                    title: '用户登录',
                    layout: 'form',
                    defaults: {width: 230},
                    defaultType: 'textfield',
                    items: [
                        {
                          fieldLabel: '用户ID',
                          name: 'uid',
                          style: 'font-size: 15px',
                          value: '0120703490423',
                          allowBlank:false,
                          blankText: '用户名不能为空',
                          width: 200
                        },
                        {
                          fieldLabel: '密  码',
                          name: 'pwd',
                          style: 'font-size: 15px',
                          inputType: 'password',
                          allowBlank: false,
                          blankText: '密码不能为空',
                          value: '123456',
                          width: 200
                        },
                        {
                            xtype: 'radio',
                            name: 'role',
                            itemCls: 'float-left',
                            clearCls: 'allow-float',
                            fieldLabel: '用户选择',
                            boxLabel: '学生',
                            inputValue: '2', // Role =2 => student
                            //hideLabel: true,
                            checked: true,
                            width: 80
                        },
                        {
                            xtype: 'radio',
                            name: 'role',
                            itemCls: 'float-left',
                            clearCls: 'allow-float',
                            boxLabel: '教师',
                            inputValue: '1', // Role =1 => teacher
                            hideLabel: true,
                            width: 80
                        }
                        ] //-- 用户角色单选
                    }, // --tab1
                    { // tab2--
                        title: '关于',
                        layout: '',
                        html: '电子作业管理系统<br/>Powered By iThink Team',
                        defaults: {width: 230}
                }]// --tab2
             }  //tab items
         ]  //items
    });

    EHSubmit.loginWin = {
                xtype: 'window',
                id:'EHSubmitLoginWin',
                title: 'EHSubmit 电子作业管理系统',
                layout:'fit',
                width:460,
                height:320,
                closeAction:'hide',
                plain: true,
                modal:true,
                collapsible: true,
                maximizable:false,
                draggable: true,
                closable: false,
                resizable:false,
                animateTarget:document.body,
                items: 
                    EHSubmit.loginForm,
                buttons: 
                    [
                        {
                            text:'登录',
                            handler: function(){
                                if(Ext.getCmp('loginForm').form.isValid()){
                                    Ext.getCmp('loginForm').form.submit({
                                        url:'AJAX/Login.ashx', 
                                        waitTitle:'提示',
                                        method: 'POST',
                                        waitMsg:'正在验证您的身份,请稍候.....',
                                        success:function(form,action){
                                            var loginResult = action.result.success;
                                            var msg = action.result.msg;
                                            
                                            Ext.MessageBox.alert('提示','登录成功,正在跳转页面...');
                                            window.location.href = 'View/' + msg;  // 跳转地址
                                        } , //success
                                        failure: function(form,action) {
                                            Ext.MessageBox.alert('错误','请与管理员联系');
                                            // 重置表单
                                            //EHSubmit.loginWin.getComponent('loginForm').form.reset();
                                        }   // failure                       
                                        }); // submit
                                    }   // if isValid 
                             }
                        }, // --- button 登录
                        {
                            text: '取消',
                            handler: function(){
                                Ext.getCmp('EHSubmitLoginWin').hide();
                            }
                        }  //  --- button 取消
                    ]
            };   
                 
        EHSubmit.validateScreen(function(){
            EHSubmit.showWin(EHSubmit.loginWin);
        });
});


</script>
</asp:Content>

